<?php
class MoodAction extends BaseAction {

	public function index() {
		import("ORG.Util.Page");
		$d_mood = D("mood");
		$count = $d_mood->count();
		$p = new Page($count,10);
		$p_display = $p->show();
		$mood_list = $d_mood->order("cTime desc")->limit($p->firstRow.','.$p->listRows)->select();

		$d_comment = D('comment');
		
		foreach ($mood_list as $key => $value) {
			//			dump($mood_list[$key]);
			$map['type'] = array('eq','mood');
			$map['tid'] = array('eq',$mood_list[$key]['id']);
			$mood_list[$key]['comment'] = $d_comment->where($map)->select();
		}

		$this->assign("mood_list", $mood_list);
		$this->assign('p_display',$p_display);
		$this->display("Index:mood_list");
	}

	public function delete() {
		$this->redirect("index/");
	}

	public function submit() {
		dump("submit");
		$data = $_POST;
		$data['cTime'] = time();
		D("mood")->add($data);
		$this->display("Index:index");
	}

}
?>